﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Brain.IO;

namespace Brain
{
    public class EditorSceneFile
    {
        public BinaryFile File;

        public EditorSceneFile()
        {
        }
        public EditorSceneFile(MemoryStream scene,
            MemoryStream sceneContent)
        {
            byte[] sceneBuffer = scene.GetBuffer();
            byte[] sceneContentBuffer = sceneContent.GetBuffer();

            Array.Resize(ref sceneBuffer, (int)scene.Length);
            Array.Resize(ref sceneContentBuffer, (int)sceneContent.Length);

            File = new BinaryFile();
            File.Files = new BinaryFileData[2];

            BinaryFileData sceneData = new BinaryFileData();
            sceneData.FileName = "scene";
            sceneData.Data = sceneBuffer;
            File.Files[0] = sceneData;

            BinaryFileData sceneContentData = new BinaryFileData();
            sceneContentData.FileName = "sceneContent";
            sceneContentData.Data = sceneContentBuffer;
            File.Files[1] = sceneContentData;
        }

        public void Write(Stream stream)
        {
            File.Write(stream);
        }

        public static EditorSceneFile Read(Stream stream)
        {
            EditorSceneFile scene = new EditorSceneFile();

            BinaryFile file = new BinaryFile();
            file.Read(stream);

            scene.File = file;

            return scene;
        }

    }
}
